﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using KCMS.BusinessLogic.Interfaces;
using StructureMap;
using KCMS.Models;
using KCMS.BusinessLogic.Models;

namespace KCMS.Controllers
{
    public class ShopFormController : Controller
    {
        private IProductImageService productImageService = ObjectFactory.GetInstance<IProductImageService>();
        private IAllowableProductSizeService allowSizeService = ObjectFactory.GetInstance<IAllowableProductSizeService>();
        public ActionResult Show(Guid productId)
        {
            List<ShopForm> model = new List<ShopForm>();
            IEnumerable<Size> sizes = (from t in allowSizeService.getByProduct(productId)
                                       orderby t.Size.Number
                                       select t.Size).ToList();
            foreach (ProductImage image in productImageService.getByProductId(productId))
            {
                model.Add(new ShopForm
                {
                    ProductId=productId,
                    ProductImage=image,
                    Sizes=sizes,
                    Quantities=new List<int>(sizes.Count())
                });
            }
            return PartialView(model);
        }

    }
}
